define(['zepto', 'wx', 'sui'], function($, wx) {
  return {
    init: function(data) {
      var that = this;
      var config = data.jsConfig;
      var isDebug = location.search.indexOf('debug=true') > 0
      wx.config({
        debug: isDebug, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: config.appid,
        timestamp: config.timestamp,
        nonceStr: config.nonce_str,
        signature: config.signature,
        jsApiList: ['checkJsApi',
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo']
      });
      
      wx.ready(function(){
        
        var shareJson = {
            title: "陆老师小课堂-口算训练",
            desc:   "来试试娃的口算能力吧~",
            link:   window.__CTX__.domain,
            imgUrl: window.__CTX__.domain + "/resource/images/edooschool.png"
        };
        
        wx.checkJsApi({
          jsApiList: ['onMenuShareTimeline',
                      'onMenuShareAppMessage',
                      'onMenuShareQQ',
                      'onMenuShareWeibo']
        });
        
        success: 
        
        wx.onMenuShareAppMessage(
          $.extend({}, shareJson, {"success": 
            function() {
              window.__CTX__.share(window.__CTX__.root + "/oral-share", {
                "current": window.location.href,
                "marks": "口算历史记录分享",
                "type": "朋友"
              })
            }
          })
        )
        
        wx.onMenuShareQQ(
          $.extend({}, shareJson, {"success": 
            function() {
              window.__CTX__.share(window.__CTX__.root + "/oral-share", {
                "current": window.location.href,
                "marks": "口算历史记录分享",
                "type": "QQ"
              })
            }
          })
        )
        wx.onMenuShareWeibo(
          $.extend({}, shareJson, {"success": 
            function() {
              window.__CTX__.share(window.__CTX__.root + "/oral-share", {
                "current": window.location.href,
                "marks": "口算历史记录分享",
                "type": "微博"
              })
            }
          })
        )
        
        wx.onMenuShareTimeline({
          title : shareJson.title + "," + shareJson.desc,
          desc: shareJson.desc,
          link:   shareJson.link,
          imgUrl:   shareJson.imgUrl,
          success:   function() {
            window.__CTX__.share(window.__CTX__.root + "/oral-share", {
              "current": window.location.href,
              "marks": "口算历史记录分享",
              "type": "朋友圈"
            })
          }
        });
      });
      
    }
  }
})


